package com.chinawlx.wlxteacher.base;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.cache.DiskCache;
import com.bumptech.glide.load.engine.cache.DiskLruCacheWrapper;
import com.bumptech.glide.module.GlideModule;

/**
 * 作者:吴名
 * 时间:16/8/13
 * 描述:
 */
public class MyGlideModule implements GlideModule {
    @Override
    public void applyOptions(final Context context, GlideBuilder builder) {
        //图片质量
        builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);

        //缓存路径
        builder.setDiskCache(new DiskCache.Factory() {

            @Override
            public DiskCache build() {
                return DiskLruCacheWrapper.get(WLXApplication.myApplication.getExternalCacheDir()
                        , 1024 * 1024 * 100);
                //最大缓存100M
            }
        });

    }

    //配置网络栈(OKHttp或者Volley,不支持Retrofit2)
    @Override
    public void registerComponents(Context context, Glide glide) {
//        glide.register(GlideUrl.class, InputStream.class, new HttpUrlGlideUrlLoader.Factory());
    }

}
